<extend name="Public/baseConf"/>
<block name="breadcrumb"> 
	<div class="row wrapper border-bottom white-bg page-heading">
	    <div class="col-lg-8">
	        <h2>{:isset($info['id'])?'编辑':'新增'}分类信息</h2>
	        <ol class="breadcrumb">
	            <li><a href="{:U('index/index')}">首页</a></li>
	            <li><a href="{:U('Category/index')}">分类管理</a></li>
	            <li class="active">
	                <strong>{:isset($info['id'])?'编辑':'新增'}分类信息</strong>
	            </li>
	        </ol>
	    </div>
	    <div class="col-lg-4">
            <div class="title-action">
 				<button class="btn btn-primary ajax-post" type="submit" target-form="form-horizontal"><i class="fa fa-check"></i>保存</button>
	            <a class="btn btn-warning" type="submit"  onclick="javascript:history.back(-1);return false;"><i class="fa fa-reply"></i>返回</a>
            </div>
        </div>
	</div> 
</block>
<block name="body">

<div class="page-content" style='width:100%;padding:0px;height:100%;margin:0px'>
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<div class="row">
	    <div class="col-lg-12">
			<div class="tabs-container">
			<ul class="nav nav-tabs">
				<li class="active"><a data-toggle="tab" href="#tab1"><i class="green fa fa-user  bigger-110"></i>基 础</a></li>
				<li><a data-toggle="tab" href="#tab2"><i class="green fa fa-user  bigger-110"></i>高 级</a></li>
			</ul>
			<form action="{:U()}" method="post" class="form-horizontal"> 
				<input type="hidden" name="id" value="{$info.id|default=''}">
				<input type="hidden" name="pid" value="{:isset($category['id'])?$category['id']:$info['pid']}">
				<!-- 基础 -->
				<div class="tab-content">
					<div id="tab1" class="tab-pane in active">
						<div class="panel-body">
						
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">上级分类</label>
								<div class="col-sm-9">
									<input type="text" class="form-control" disabled="disabled" value="{$category['title']|default='无'}"/>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">分类名称<small>（名称不能为空）</small></label> 
								<div class="col-sm-9">
									<input type="text" name="title" class="form-control" value="{$info.title|default=''}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">分类标识<small>（英文字母）</small></label> 
								<div class="col-sm-9">
									<input type="text" name="name" class="form-control" value="{$info.name|default=''}">
								</div>
							</div>
	                   		<div class="hr-line-dashed"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">分组定义</label> 
								<div class="col-sm-9">
										<textarea name="groups" class="form-control">{$info.groups|default=''}</textarea>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">发布内容<small>（是否允许发布内容）</small></label> 
								<div class="col-sm-9">
								
									<div class="radio radio-info radio-inline">
                        				<input type="radio" id="allow_publish___0" name="allow_publish" value="0"/>
                                        <label for="allow_publish___0">不允许</label>
                                    </div>
									<div class="radio radio-info radio-inline">
                        				<input type="radio" id="allow_publish___1" name="allow_publish" value="1"/>
                                        <label for="allow_publish___1">仅允许后台 </label>
                                    </div>
                                    <div class="radio radio-info radio-inline">
                        				<input type="radio" id="allow_publish___2" name="allow_publish" value="2"/>
                                        <label for="allow_publish___2">允许前后台</label>
                                    </div> 
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label">是否审核<small>（在该分类下发布的内容是否需要审核）</small></label> 
								<div class="col-sm-9">
									<div class="radio radio-info radio-inline">
                        				<input type="radio" id="check___0" name="check" value="0"/>
                                        <label for="check___0">不需要</label>
                                    </div> 
                                    <div class="radio radio-info radio-inline">
                        				<input type="radio" id="check___1" name="check" value="1"/>
                                        <label for="check___1">需要</label>
                                    </div>  
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group"> 
								<label class="col-sm-3 control-label">允许文档类型</label> 
								<div class="col-sm-9">
									<volist name=":C('DOCUMENT_MODEL_TYPE')" id="type">
										<div class="checkbox checkbox-inline checkbox-info">
	                                		<input id="type{$type}" type="checkbox" name="type[]" value="{$key}"/>
                                            <label for="type{$type}"> {$type} </label>
                                        </div>
									</volist>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">列表绑定文档模型<small>（列表支持发布的文档模型）</small></label> 
								<div class="col-sm-9">
									<volist name=":get_document_model()" id="list"> 
										<div class="checkbox checkbox-inline checkbox-info">
	                                		<input id="model{$list.title}" type="checkbox" name="model[]" value="{$list.id}"/>
                                            <label for="model{$list.title}"> {$list.title} </label>
                                        </div>
									</volist>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">子文档绑定绑定模型<small>（子文档支持发布的文档模型）</small></label> 
								<div class="col-sm-9">
									<volist name=":get_document_model()" id="list"> 
										<div class="checkbox checkbox-inline checkbox-info">
	                                		<input id="model_sub{$list.title}" type="checkbox" name="model_sub[]" value="{$list.id}"/>
                                            <label for="model_sub{$list.title}"> {$list.title} </label>
                                        </div>
									</volist>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right">分类图标</label>  
								<div class="col-sm-9">
								<div class="row"> <input type="file" id="upload_picture">  </div>
									<input type="hidden" name="icon" id="icon" value="{$info['icon']|default=''}"/>
									<div class="upload-img-box">
										<notempty name="info['icon']">
											<div class="upload-pre-item"><img src="{$info.icon|get_cover='path'}"/></div>
										</notempty>
									</div>
								</div> 
							</div>
	                    	<div class="hr-line-dashed"></div>
							<script type="text/javascript">
							//上传图片
						    /* 初始化上传插件 */
							$("#upload_picture").uploadify({
						        "height"          : 30,
						        "swf"             : "__STATIC__/uploadify/uploadify.swf",
						        "fileObjName"     : "download",
						        "buttonText"      : "上传图片",
						        "uploader"        : "{:U('File/uploadPictureFTP',array('session_id'=>session_id()))}",
						        "width"           : 120,
						        'removeTimeout'	  : 1,
						        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
						        "onUploadSuccess" : uploadPicture,
						        'onFallback' : function() {
						            alert('未检测到兼容版本的Flash.');
						        }
						    });
							function uploadPicture(file, data){
						    	var data = $.parseJSON(data);
						    	var src = ''; 
						        if(data.status){
						        	$("#icon").val(data.id);
						        	src = data.url || '__ROOT__' + data.path;
						        	$("#icon").parent().find('.upload-img-box').html(
						        		'<div class="upload-pre-item"><img src="' + src + '"/></div>'
						        	);
						        } else {
						        	updateAlert(data.info);
						        	setTimeout(function(){
						                $('#top-alert').find('button').click();
						                $(that).removeClass('disabled').prop('disabled',false);
						            },1500);
						        }
						    }
							</script>
						</div>
					</div>
					<!-- 高级 -->
					<div id="tab2" class="tab-pane">
					<div class="panel-body">
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">可见性<small>（是否对用户可见，针对前台）</small></label> 
							<div class="col-sm-9">
								<select name="display" class='form-control'>
									<option value="1">所有人可见</option>
									<option value="0">不可见</option>
									<option value="2">管理员可见</option>
								</select>
							</div>
						</div>
	                    <div class="hr-line-dashed"></div>
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">排序<small>（仅对当前层级分类有效）</small></label> 
							<div class="col-sm-9">
								<input type="text" name="sort" class="form-control" value="{$info.sort|default=0}">
							</div>
						</div>
	                    <div class="hr-line-dashed"></div>
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">列表行数</label> 
							<div class="col-sm-9">
								<input type="text" name="list_row" class="form-control" value="{$info.list_row|default=10}">
							</div>
						</div> 
	                    <div class="hr-line-dashed"></div>
						<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">当前层级</label> 
							<div class="col-sm-9">
								<input type="text" name="levels" readonly class="form-control" value="{$category['levels']|default=1}">
							</div>
						</div> 
	                    <div class="hr-line-dashed"></div>
					</div>
					</div>
					<!-- 高级 -->
					<div id="tab2" class="tab-pane">
						<div class="panel-body">
							<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">网页标题</label>
								<div class="col-sm-9">
									<input type="text" name="meta_title" class="form-control" value="{$info.meta_title|default=''}">
								</div>
							</div>
	                   	 	<div class="hr-line-dashed"></div>
							<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">关键字</label>
								<div class="col-sm-9">
									<textarea name="keywords" class="form-control">{$info.keywords|default=''}</textarea>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">描述</label>
								<div class="col-sm-9">
									<textarea name="description" class="form-control">{$info.description|default=''}</textarea>
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">频道模板</label>
								<div class="col-sm-9">
									<input type="text" name="template_index" class="form-control" value="{$info.template_index|default=''}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">列表模板</label>
								<div class="col-sm-9">
									<input type="text" name="template_lists" class="form-control" value="{$info.template_lists|default=''}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">详情模板</label>
								<div class="col-sm-9">
									<input type="text" name="template_detail" class="form-control" value="{$info.template_detail|default=''}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
							<div class="form-group">
							<label class="col-sm-3 control-label no-padding-right">编辑模板</label> 
								<div class="col-sm-9">
									<input type="text" name="template_edit" class="form-control" value="{$info.template_edit|default=''}">
								</div>
							</div>
	                    	<div class="hr-line-dashed"></div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
</block>

<block name="script">
	<script type="text/javascript">
		<present name="info.id">
		Think.setValue("allow_publish", {$info.allow_publish|default=1});
		Think.setValue("check", {$info.check|default=0});
		Think.setValue("model[]", {$info.model|json_encode} || [1]);
		Think.setValue("model_sub[]", {$info.model_sub|json_encode} || [1]);
		Think.setValue("type[]", {$info.type|json_encode} || [2]);
		Think.setValue("display", {$info.display|default=1});
		Think.setValue("reply", {$info.reply|default=0});
		Think.setValue("reply_model[]", {$info.reply_model|json_encode} || [1]);
		</present>
		$(function(){ 
			$("input[name=reply]").change(function(){
				var $reply = $(".form-group.reply");
				parseInt(this.value) ? $reply.show() : $reply.hide();
			}).filter(":checked").change();
		});
	</script>
</block>
